package org.aplikator.client.shared.descriptor;

import org.aplikator.client.local.widgets.HasFields;
import org.aplikator.client.local.widgets.TextFieldWidget;

import com.google.gwt.user.client.ui.Widget;
import org.jboss.errai.common.client.api.annotations.Portable;

@SuppressWarnings("serial")
//@JsonTypeName("textfield")
//@Portable
public class TextFieldDTO extends WidgetPropertyDTOBase implements RenderWidgetAware {

	public static final String TYPE_KEY = "textfield";
	
    @SuppressWarnings("unused")
    public TextFieldDTO() {//TODO custom marshaller
    }

    public TextFieldDTO(PropertyDTO property) {
        super(property);
    }

    @Override
    public Widget getWidget(HasFields form)  {
        TextFieldWidget field = new TextFieldWidget(property.getLocalizedName(), property, getSize());
        field.setEnabled(isEnabled());
        if (property.getRefferedThrough() != null) {
            field.setEnabled(false);
        }
        form.registerDataField(field);
        return field;
    }

}
